package com.stockz.equity.charting.painter.shape;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.util.HashSet;
import java.util.Set;

import org.springframework.stereotype.Component;

import com.stockz.equity.charting.model.Point;
import com.stockz.equity.charting.model.Shape;
import com.stockz.equity.charting.util.SwingUtil;
import com.stockz.equity.charting.view.StockChart;
import com.stockz.equity.charting.view.StockChartPanelState;

@Component
public class PointPainter implements ShapePainter<Point,StockChart> {

	Set<Class<? extends Shape>> classSet = new HashSet<Class<? extends Shape>>();
	
	public PointPainter(){
		classSet.add(Point.class);
	}
	
	@Override
	public void paint(Graphics2D g, Point shape,StockChart view, Rectangle rectangle) {
		StockChartPanelState state = view.getStockChartPanel().getStockChartPanelState();
		java.awt.Point point = SwingUtil.fitPoint(state, shape);
		g.setColor(Color.blue);
		g.fillRoundRect(point.x, point.y, 10, 10, 3, 3);
	}
	
	public  boolean supports(Class<Point> c){
		for(Class<? extends Shape> s : classSet){
			if(s.isAssignableFrom(c)){
				return true;
			}
		}
		return false;
	}
}
